<!DOCTYPE html>
<!--
Template Name: Metronic - Responsive Admin Dashboard Template build with Twitter Bootstrap 3.1.1
Version: 2.0.2
Author: KeenThemes
Website: http://www.keenthemes.com/
Contact: support@keenthemes.com
Purchase: http://themeforest.net/item/metronic-responsive-admin-dashboard-template/4021469?ref=keenthemes
License: You must have a valid license purchased only from themeforest(the above link) in order to legally use the theme for your project.
-->
<!--[if IE 8]>
<html lang="en" class="ie8 no-js">
<![endif]-->
<!--[if IE 9]>
<html lang="en" class="ie9 no-js">
<![endif]-->
<!--[if !IE]>
<!-->
<!--<![endif]-->
<!-- BEGIN HEAD -->
<!-- BEGIN BODY -->
<style type="text/css">
    /*	ul.page-sidebar-menu{
        height: 1200px;
    }*/
    .table_btn_box{
        margin-bottom: 5px;
        float: left;
    }
    .modal-content .modal-footer button.btn-primary {
        margin-top:0;
        margin-bottom:0;
    }
    .btn-div{
        float: left;top: 10px;margin-bottom: 5px;padding-left: 10px;
    }
    .row{
        margin: 0;
    }
    .marginTop{
        padding-top: 15px;
    }

    .menu {
        color: #338ee7;
        font-weight: bold;
    }

    .leaf {
        margin-left: 31px;
    }
</style>
<body class="page-header-fixed">
<!-- BEGIN CONTAINER -->
<!-- BEGIN CONTENT -->
<!--表格操作按钮组-->
<div class="btn-div">
    <a class="btn blue" href="javascript:;"  data-target="#roleModel"
       data-toggle="modal" ng-click="addRole();"> <i class="fa fa-plus"></i>
        新增
    </a>
</div>
<table class="table table-striped table-bordered table-hover" id="table_1">
    <thead>
    <tr>
        <th>角色名称</th>
        <th>归属类型</th>
        <th>归属对象</th>
        <th>是否使用</th>
        <th>操作</th>
    </tr>
    </thead>
    <tbody>
    <tr class="odd gradeX" ng-repeat="role in roleList  track by $index" pg-loaded="{{$last}}" target-table="table_1">
        <td>
            <span ng-bind="role.role_name | commonSubString"></span>
        </td>
        <td>
            <span ng-bind="role.entity_type | getValueInStaticFilter : 'entityTypeArray'"></span>
        </td>
        <td>
            <span ng-bind="role.entity_name | commonSubString"></span>
        </td>
        <td>
            <span ng-bind="role.valid_flag | getValueInStaticFilter : 'validArray'"></span>
        </td>
        <td>
            <a class="btn" href="javascript:;"  data-target="#roleModel"
               data-toggle="modal" ng-click="updateRole(role);">修改</a>
            <a class="btn" href="javascript:;"  data-target="#urlResourceList"
               data-toggle="modal" ng-click="allotUrl(role);">资源分配</a>
        </td>
    </tr>
    </tbody>
</table>
<tm-pagination conf="paginationConf"></tm-pagination>

<div id="roleModel" class="modal fade" role="dialog" aria-hidden="true" data-backdrop="false">
    <div class="modal-dialog">
        <div class="modal-content">
            <form class="w5c-form demo-form" role="form" w5c-form-validate="vm.validateOptions" novalidate name="validateForm">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true" ng-click="validateForm.reset()">×</button>
                <h4 class="modal-title" ng-bind="titleText">角色新增/修改</h4>
            </div>
            <div class="modal-body form">
                <div class="form-group">
                    <div class="row">
                        <label class="col-sm-3 control-label text-right"><span class="star-color">* </span>角色名称</label>
                        <div class="col-sm-8">
                            <div class="input-group">
                                <input type="text" class="form-control" ng-model="selectedRole.role_name" required="" name="role_name" ng-maxlength="20" ng-pattern="/^[\u4e00-\u9fa5\w]*$/" placeholder="请输入字母、数字、中文和下划线组合"/>
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <label class="col-sm-3 control-label text-right"><span class="star-color">* </span>归属类型</label>
                        <div class="col-md-8">
                            <div class="radio-list">
                                <label class="radio-inline">
                                    <input ng-model="selectedRole.entity_type" type="radio"  value="1"
                                           ng-selected="selectedRole.entity_type==1">运营商</label>
                                <label class="radio-inline">
                                    <input ng-model="selectedRole.entity_type" type="radio"  value="2"
                                           ng-selected="selectedRole.entity_type==2">运营商分支机构</label>
                                </br>
                                <label class="radio-inline" style="padding: 0">
                                    <input ng-model="selectedRole.entity_type" type="radio"  value="3"
                                           ng-selected="selectedRole.entity_type==3">厂商</label>
                                <label class="radio-inline" style="padding-left: 34px">
                                    <input ng-model="selectedRole.entity_type" type="radio"  value="4"
                                           ng-selected="selectedRole.entity_type==4">合作商</label>
                            </div>
                        </div>
                    </div>
                <div class="row">
                    <label class="col-sm-3 control-label text-right"><span class="star-color">* </span>归属对象</label>
                    <div class="col-sm-8">
                        <div class="input-group">
                            <select class="form-control" ng-if="!!selectedRole.entity_type&&selectedRole.entity_type==1"
                                    ng-options="operMechant.oper_merchant_id as operMechant.oper_name for operMechant in operMechantList "
                                    ng-model="selectedRole.entity_id"   required=""  name="entity_id" w5c-dynamic-element id="selectEntity">
                                <option value="">请选择运营商</option>
                            </select>
                            <select class="form-control" ng-if="!!selectedRole.entity_type&&selectedRole.entity_type==2"
                                    ng-options="operMerchantBranch.oper_merchant_branch_id as operMerchantBranch.oper_name for operMerchantBranch in operMerchantBranchList "
                                    ng-model="selectedRole.entity_id"  required=""  name="entity_id" w5c-dynamic-element id="selectEntity">
                                <option value="">请选择运营商分支机构</option>
                            </select>
                            <select class="form-control" ng-if="!!selectedRole.entity_type&&selectedRole.entity_type==3"
                                    ng-options="factory.factory_id as factory.factory_name for factory in factoryList "
                                    ng-model="selectedRole.entity_id"  required=""  name="entity_id" w5c-dynamic-element id="selectEntity">
                                <option value="">请选择厂商</option>
                            </select>
                            <select class="form-control" ng-if="!!selectedRole.entity_type&&selectedRole.entity_type==4"
                                    ng-options="merchant.merchant_id as merchant.name for merchant in merchantList "
                                    ng-model="selectedRole.entity_id"  required=""  name="entity_id" w5c-dynamic-element id="selectEntity">
                                <option value="">请选择合作商</option>
                            </select>
                        </div>
                    </div>
                </div>
                <div class="row marginTop" ng-if="'insert'!=modifyType">
                    <label class="col-sm-3 control-label text-right">是否启用</label>
                    <div class="col-md-8">
                        <div class="radio-list">
                            <label class="radio-inline">
                                <input ng-model="selectedRole.valid_flag" type="radio"  value="1"
                                       ng-selected="selectedRole.valid_flag==1">启用</label>
                            <label class="radio-inline">
                                <input ng-model="selectedRole.valid_flag" type="radio"  value="0"
                                       ng-selected="selectedRole.valid_flag==0">停用</label>
                        </div>
                    </div>
                </div>
                </div>
            </div>
            <div class="modal-footer">
                    <button type="button" class="btn btn-danger" data-dismiss="modal" ng-click="validateForm.reset()"> <i class="fa fa-times"></i>
                        关闭
                    </button>
                    <button type="button" class="btn btn-primary" w5c-form-submit="modifyRole();">
                        <i class="fa fa-check"></i>
                        保存
                    </button>
                </div>
            </form>
        </div>
        
    </div>
</div>
<div id="urlResourceList" class="modal fade" role="dialog" aria-hidden="true" data-backdrop="false" >
    <div class="modal-dialog" style="width:680px">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"
                        aria-hidden="true">×</button>
                <h4 class="modal-title">资源分配管理</h4>
            </div>

            <div class="modal-body">
                <button class="btn btn-success btn-sm" ng-click="expandAll()">全部展开</button>
                <button class="btn btn-success btn-sm" ng-click="collapseAll()">全部折叠</button>

                <div ui-tree data-drag-enabled="false">
                    <ul ui-tree-nodes="" ng-model="urlResourceList" id="tree-root" style="list-style:none">
                        <li ng-repeat="item in urlResourceList.subTree" ui-tree-node ng-include="'sysManage/urlItem.html'"></li>
                    </ul>
                </div>

            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-danger" data-dismiss="modal">
                    <i class="fa fa-times"></i>
                    关闭
                </button>
                <button type="button" class="btn btn-primary" ng-click="assign();">
                    <i class="fa fa-check"></i>
                    保存
                </button>
            </div>
        </div>
    </div>
</div>
<!-- END CONTENT -->

<!-- END CONTAINER -->

<!-- BEGIN JAVASCRIPTS(Load javascripts at bottom, this will reduce page load time) -->
<!-- BEGIN CORE PLUGINS -->

</body>
<!-- END BODY -->

</html>